//package com.xuelang.pipeline.app.resource.impl;
//
//import com.netflix.hystrix.exception.HystrixBadRequestException;
//import com.netflix.hystrix.exception.HystrixRuntimeException;
//import com.netflix.hystrix.exception.HystrixTimeoutException;
//import com.xuelang.pipeline.app.resource.PodService;
//import com.xuelang.pipeline.app.resource.request.PodListRequest;
//import com.xuelang.pipeline.app.resource.request.PodLogRequest;
//import com.xuelang.pipeline.client.common.result.ApiResult;
//import feign.hystrix.FallbackFactory;
//import io.kubernetes.client.openapi.models.V1PodList;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
///**
// * Pod服务fegin调用失败回调实现类
// *
// * @author xiwen.zxg
// * @since 2024/5/15
// */
//@Slf4j
//@Service
//public class PodServiceFallbackImpl implements FallbackFactory<PodService> {
//
//
//    @Override
//    public PodService create(Throwable throwable) {
//        String fallReason = throwable.getMessage();
//        if (throwable instanceof HystrixTimeoutException) {
//            fallReason = "Socket connect timeout.";
//        } else if (throwable instanceof HystrixBadRequestException) {
//            fallReason = "Bad Request.";
//        } else if (throwable instanceof HystrixRuntimeException) {
//            fallReason = "Runtime exception";
//        }
//
//        final String returnFallReason = fallReason;
//
//        log.error("调用fegin数据接口失败。接口名称:{}；失败原因:{}", this.getClass().getName(), fallReason);
//        return new PodService() {
//
//            ApiResult apiResult = ApiResult.fail("worker返回异常：" + returnFallReason);
//
//            @Override
//            public ApiResult<V1PodList> list(PodListRequest podListRequest) {
//                return apiResult;
//            }
//
//            @Override
//            public ApiResult<String> log(PodLogRequest podLogRequest) {
//                return apiResult;
//            }
//
//
//        };
//    }
//
//}
